var csInterface = new CSInterface();

// 个人主页
var homePageElement = document.querySelector("#homePage");
homePageElement.addEventListener("click", callHomepage);

function callHomepage() {
  window.cep.util.openURLInDefaultBrowser('https://gitee.com/brzjomo');
}

// 调用函数1
var runButtonInside = document.querySelector("#btn-inside");
runButtonInside.addEventListener("click", buttonInside);

// 调用函数2
var runButtonOutside = document.querySelector("#btn-outside");
runButtonOutside.addEventListener("click", buttonOutside);

// 调用函数3
var runButtonParseInt = document.querySelector("#btn-parseInt");
runButtonParseInt.addEventListener("click", buttonParseInt);

// 函数1
function buttonInside() {
  // 获取布尔-是否取整
  var IfRoundingElement = document.getElementById("ifRounding");
  var ifRounding = IfRoundingElement.checked;

  // 获取字号
  var fontSize = parseInt(document.getElementsByName("fontSize")[0].value);

  csInterface.evalScript('inside(' + fontSize + ', ' + ifRounding +')');
}

// 函数2
function buttonOutside() {
  // 获取布尔-是否取整
  var IfRoundingElement = document.getElementById("ifRounding");
  var ifRounding = IfRoundingElement.checked;

  // 获取布尔-是否标注色值
  var IfTagColorValueElement = document.getElementById("tagColorValue");
  var ifTagColorValue = IfTagColorValueElement.checked;

  // 获取字号
  var fontSize = parseInt(document.getElementsByName("fontSize")[0].value);

  // 引入outside.jsx
  const path = csInterface.getSystemPath(SystemPath.EXTENSION);
  csInterface.evalScript(`$.evalFile("${path}/colorCodeTool/jsx/outside.jsx")`);

  csInterface.evalScript('outside(' + fontSize + ', ' + ifRounding + ', ' + ifTagColorValue +')');
}

// 函数3
function buttonParseInt() {
  // 引入parseInt.jsx
  const path = csInterface.getSystemPath(SystemPath.EXTENSION);
  csInterface.evalScript(`$.evalFile("${path}/colorCodeTool/jsx/parseInt.jsx")`);

  csInterface.evalScript('parseInt(' +')');
}
